package uk.ac.cam.juliet.zedcat.socialnetworking;
import java.sql.Timestamp;

import javax.swing.JTextArea;
import javax.swing.JTextField;

/**
 *  A class to control text entry to the status window in the centre of the GUI window.
 *  @author Daniel Wright
 */

public class Logger {

	private JTextArea logArea;
	private JTextArea tPollCount;
	private JTextArea tLastTimestamp;
	private JTextArea lastMessage;
	private JTextArea tMessageCount;
	private JTextArea tNumberOfSightingsProcessed;
	private int iPollCount = 0;
	private int iMessageCount = 0;
	private int iNumberOfSightingsProcessed;
	
	
	public Logger(JTextArea logArea, JTextArea tPollCount2,JTextArea tTimestamp, JTextArea tMostRecentUpdate, JTextArea tMessageCount2, JTextArea tNumberOfSightingsProcessed2) {
		this.logArea = logArea;
		this.tPollCount = tPollCount2;
		this.tLastTimestamp = tTimestamp;
		this.lastMessage = tMostRecentUpdate;
		this.tMessageCount = tMessageCount2;
		this.tNumberOfSightingsProcessed = tNumberOfSightingsProcessed2;
	}
	
	public void setTimeStamp(Timestamp t) {
		tLastTimestamp.setText(t.toString());
	}
	
	public void log (String message) {
		logArea.append("\n" + message);
		logArea.setCaretPosition(logArea.getDocument().getLength());}
	
	public void increasePollCount() {
		tPollCount.setText(Integer.toString(++iPollCount));
	}

	public void setLastMessage(String st) {
		this.lastMessage.setText(st);
	}

	public void increaseMessageCount() {
		tMessageCount.setText(Integer.toString(++iMessageCount));
	}
	
	public void increaseNumberOfSightingsProcessed() {
		tNumberOfSightingsProcessed.setText(Integer.toString(++iNumberOfSightingsProcessed));
	}
	
}
